<script language="JavaScript">
//发布脚本检查
function publishScript()
{
    if(form1.file.value == "")
    {
        alert("请选择要发布脚本参数文件！");
        return false;
    }
    return true;
}
//显示脚本组信息
function displayScript(obj){
 if(obj.value==""){
    return false;
 }
   var selectedTaskID = obj.options[obj.selectedIndex].value;
   url = "task?operation=getAllScripts"+"&scriptName="+encodeURIComponent(selectedTaskID)+"&taskID="+'QYKB',"_self";
   window.location = encodeURI(url);
}
//显示脚本组
function getAllScriptSuits(obj){
   window.location = "task?operation=showManagerScriptPage"+"&taskID="+'QYKB',"_self";
}

</script>

<table width=100% border="0">
       <tr height=26 class="clsTrHeader" >
         <%=render(:partial => '/share/subtitle', :locals=>{:title1=>"任务管理->#{session[:task].name}", :title2=>"脚本管理"})%>
       </tr>
  <tr>
        <form action="/taskman/publish_script" method="post" enctype="multipart/form-data" name="form1">
              <td valign="middle" colspan=3>&nbsp;&nbsp;请选择需要发布的脚本文件：&nbsp;&nbsp;
                  <input type="file" name="file"/>
                 <input type="hidden" name="taskID" value='QYKB'>
                 <input type="submit" value="发布脚本" onclick="return publishScript()"/>
               </td>
        </form>

  </tr>
   <tr>
                           <td colspan=2 nowrap>
                 <%= form_remote_tag :update=>'script', :url=>{:action=>'show_script'}%>
                                   <SELECT id=seclect1 name='select1' onChange="javascript:form.onsubmit();" >
                                   
                                   <%=options_from_collection_for_select(@scripts, 'scriptid', 'name', @active)%>
                                   
                                   </SELECT>
                          <input type=button onclick="activeScriptSuits()" name="activeScriptSuit" value="激活">
                          <input type=button onclick="deleteScriptSuits()" name="deleteScriptSuit" value="删除">
                <%= end_form_tag %>
                    </td>
                          <td colspan=1 nowrap align="right">
                            <% if session[:task].activescriptsuitname.to_s != ''%>    
                                    当前激活脚本:<%=session[:task].activescriptsuitname%>&nbsp;&nbsp;
                            <% end%>
                          <a id="imgA" style="display:none" href="javascript:displayAll()"><img id="imgCtl" src="../img/down.gif" border="0" alt="展开/收缩"></a>

                          &nbsp;
                    </td>
   </tr>
</table>

<div id="script">
<% if @scripts.size > 0 %>
    <% script = CTaskScript.new %>
    <% script.parse(EncodeUtil.change("GB2312", "UTF-8", @scripts[0].content)) %>
    <%= render :partial=>'showscript', :locals=>{:script=> script} %>
<% end%>
</div>


<script language="javascript">

 if(document.getElementById("seclect1").value==""){
     document.getElementById("imgCtl").style.display = "none";
 }

function displayAll(){
//判断状态
var flag=false;
for(var i=1;i<5;i++){
   if(eval("document.all.advshow"+i).checked == true){
      flag = true;
   }
}
if(flag){
  for(var i=1;i<5;i++){
    eval("t" + i).style.display = "none";
    eval("document.all.advshow"+i).checked = false;
  }
  document.getElementById("imgCtl").src = "../img/up.gif";
}else{
  for(var i=1;i<5;i++){
    eval("t" + i).style.display = "";
    eval("document.all.advshow"+i).checked = true;
  }
  document.getElementById("imgCtl").src = "../img/down.gif";
}
}
//设置（展开/收缩）图标
function imgStatus(){
    var flag=false;
    for(var i=1;i<5;i++){
       if(eval("document.all.advshow"+i).checked == true){
          flag = true;
       }
    }
  if(flag){
    document.getElementById("imgCtl").src = "../img/down.gif";
  }else{
    document.getElementById("imgCtl").src = "../img/up.gif";
  }
}
function showadv1(){
    if (document.all.advshow1.checked == true) {
    t1.style.display = "";
    }else{
    t1.style.display = "none";
    }
    imgStatus();
}
function showadv2(){
    if (document.all.advshow2.checked == true) {
    t2.style.display = "";
    }else{
    t2.style.display = "none";
    }
    imgStatus();
}
function showadv3(){
    if (document.all.advshow3.checked == true) {
    t3.style.display = "";
    }else{
    t3.style.display = "none";
    }
    imgStatus();
}
function showadv4(){
    if (document.all.advshow4.checked == true) {
    t4.style.display = "";
    }else{
    t4.style.display = "none";
    }
    imgStatus();
}
//激活脚本组
function activeScriptSuits(){
 if(document.getElementById("seclect1").value==""){
    alert("请选择需要激活的脚本组！");
    return;
 }
   url = "/taskman/active_script/" + document.getElementById("seclect1").value;
   window.location = encodeURI(url);
}
//删除脚本组
function deleteScriptSuits(){
 if(document.getElementById("seclect1").value==""){
    alert("请选择需要删除的脚本组！");
    return;
 }
   if(confirm("确认要删除选中脚本组吗？")){
     url = "/taskman/delete_script/"+ document.getElementById("seclect1").value;
     window.location = encodeURI(url);
   }
}
 if(null!=null){
   displayScript(document.getElementById("seclect1"));
}
</script>